package com.mingqijia.gassafety.job.controller;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.db.entity.AppealLog;
import com.mingqijia.gassafety.db.entity.vo.BatchAppealVO;
import com.mingqijia.gassafety.db.entity.vo.HistoryBrokenVO;
import com.mingqijia.gassafety.db.entity.vo.LatestLogListVO;
import com.mingqijia.gassafety.db.mapper.HistoryBrokenMapper;
import com.mingqijia.gassafety.job.service.AppealLogService;
import com.mingqijia.gassafety.job.service.HistoryBrokenService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/inner/v1/batch/appeal")
public class BatchAppealController {

    @Autowired
    AppealLogService appealLogService;

    @Autowired
    HistoryBrokenService historyBrokenService;

    @PostMapping("/brokenLog")
    public CommonResponse<String> batchAppealBrokenLog(@RequestBody BatchAppealVO batchAppealVO){
        appealLogService.batchAppealBrokenLog(batchAppealVO);
        return CommonResponse.success("处理成功");
    }


    @XxlJob("brokenLogUpdate")
    public ReturnT<String>  brokenLogUpdate(String param){
        XxlJobLogger.log("XXLJOB-warnStrategy start..." );
        log.info("接收到的参数为{}", param);
        historyBrokenService.brokenLogUpdate(param);
        XxlJobLogger.log("XXLJOB-warnStrategy end..." );
        return ReturnT.SUCCESS;
    }
}
